package com.hzsai.controller;

import com.hzsai.entity.HttpStatus;
import com.hzsai.entity.ResponseEntity;
import com.hzsai.kafka.KafkaSender;
import com.hzsai.service.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: hzsai
 * @date : 2020/3/25
 * usage:
 **/
@RestController
public class KafkaController {

    private final PushService pushService;

    public KafkaController(PushService pushService) {
        this.pushService = pushService;
    }

    @PostMapping("/kafka/messages/")
    public ResponseEntity send(@RequestParam String message) {
        pushService.push(message);
        return ResponseEntity.re(HttpStatus.OK);
    }
}
